# Maintainer: David Runge <dvzrv@archlinux.org>

_name=zopfli
pkgname=python-zopfli
pkgver=0.2.2
pkgrel=2
pkgdesc="Python bindings to zopfli"
arch=(loong64 x86_64)
url="https://github.com/obp/py-zopfli"
license=(Apache)
depends=(python)
makedepends=(python-build python-installer python-setuptools python-setuptools-scm python-wheel)
checkdepends=(python-pytest)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.zip)
sha512sums=('5fd26039ce0bd910714fc4706a72d04bb5cf794957547943174ef12efe089c932802cc6bef4840a532f24d93fa726c0c23b0b1c2e6ec9eb3209c2f54b0eb8ba0')
b2sums=('30bc3ed16c82e9527e5445b0fd758bf841ae970f4b10b6ebe3d88db5cf085a5b8e560e39282cfaacb6074184b08da7c142da330f7ba582fe35b5c1fdbdb0bd51')

build() {
  cd $_name-$pkgver
  export PDM_PEP517_SCM_VERSION=$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  pytest -vv
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 README.rst -t "$pkgdir/usr/share/doc/$pkgname/"
}
